import java.lang.Math;

/**
 * @author Remi Destigny
 * 
 * Basic vector class used to store X and Y coordinates. This class also provide some utility 
 * functions like vector norm or distance from a point to another
 */
public class Vector {

	public double x;
	public double y;
	
	/**
	 * Constructor from 2 points
	 * @param ax X coordinate for first point
	 * @param ay Y coordinate for first point
	 * @param bx X coordinate for second point
	 * @param by Y coordinate for second point
	 */
	public Vector(double ax, double ay, double bx, double by) {
		x = ax - bx;
		y = ay - by;
	}
	
	/**
	 * Constructor from 1 point
	 * @param x X coordinate of the point
	 * @param y Y coordinate of the point
	 */
	public Vector(double x, double y) {
		this.x = x;
		this.y = y;
	}
	
	/**
	 * Compute the norm of the vector
	 * @return The vector's norm
	 */
	public double getNorm() {
		return Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
	}
	
	/**
	 * Compute the distance from a vector to another
	 * @param v The other vector
	 * @return The distance from this vector to vector v
	 */
	public double getDistanceFrom(Vector v) {
		return Math.sqrt(Math.pow(v.x - x, 2) + Math.pow(v.y - y, 2));
	}
		

	@Override
	public String toString() {
		return "Vector [x=" + x + ", y=" + y + "]";
	}
}
